package com.lagou.SqlSessionFactory;

import com.lagou.config.XMLConfigBuilder;
import com.lagou.io.Resources;
import com.lagou.pojo.Configuration;
import org.dom4j.DocumentException;

import java.beans.PropertyVetoException;
import java.io.InputStream;

/**
 * <pre>
 * 描述：TODO
 * </pre>
 *
 * @类名：com.lagou.SqlSessionFactory.SqlSessionFactoryBuilder
 * @作者 mengwei
 * 创建日期：2020/9/27 17:22
 */
public class SqlSessionFactoryBuilder {

    public SqlSessionFactory build(InputStream inputStream) throws DocumentException, PropertyVetoException {
//        使用dom4j解析配置文件，解析的结果放在Configuration里
        Configuration config = new XMLConfigBuilder().parseConfig(inputStream);
//        创建SQLSessionFactory对象
        DefaultSqlSessionFactory defaultSqlSessionFactory = new DefaultSqlSessionFactory(config);

        return defaultSqlSessionFactory;


    }
}
